﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:conv="clr-namespace:TimeSeriesFramework.UI.Converters;assembly=TimeSeriesFramework.UI"
                    xmlns:util="clr-namespace:TimeSeriesFramework.UI;assembly=TimeSeriesFramework.UI.WPF"
                    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation">

    <sys:Double x:Key="XXSmallTextSize">5</sys:Double>
    <sys:Double x:Key="XSmallTextSize">6</sys:Double>
    <sys:Double x:Key="SmallerTextSize">8</sys:Double>
    <sys:Double x:Key="SmallTextSize">9</sys:Double>
    <sys:Double x:Key="TextSize">12</sys:Double>
    <sys:Double x:Key="LargeTextSize">14</sys:Double>
    <sys:Double x:Key="LargerTextSize">18</sys:Double>
    <sys:Double x:Key="XLargeTextSize">24</sys:Double>
    <sys:Double x:Key="XXLargeTextSize">36</sys:Double>

    <sys:Double x:Key="BlankItemSize">10</sys:Double>
    <sys:Double x:Key="XXXSmallItemSize">25</sys:Double>
    <sys:Double x:Key="XXSmallItemSize">50</sys:Double>
    <sys:Double x:Key="XSmallItemSize">75</sys:Double>
    <sys:Double x:Key="SmallerItemSize">100</sys:Double>
    <sys:Double x:Key="SmallItemSize">125</sys:Double>
    <sys:Double x:Key="ItemSize">150</sys:Double>
    <sys:Double x:Key="LargeItemSize">175</sys:Double>
    <sys:Double x:Key="LargerItemSize">200</sys:Double>
    <sys:Double x:Key="XLargeItemSize">250</sys:Double>
    <sys:Double x:Key="XXLargeItemSize">300</sys:Double>
    <sys:Double x:Key="XXXLargeItemSize">500</sys:Double>

    <LinearGradientBrush x:Key="MenuBackgroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFB3C8D6" Offset="0"/>
        <GradientStop Color="#FFE1E9EE" Offset="0.25"/>
        <GradientStop Color="#FFE1E9EE" Offset="0.75"/>
        <GradientStop Color="#FFB3C8D6" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="HeaderRowBackgroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFB3C8D6" Offset="0"/>
        <GradientStop Color="#FFE1E9EE" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="MainTitleForegroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFFFFF" Offset="0.4"/>
        <GradientStop Color="#FF3FA6FF" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="MainBackgroundBrush" EndPoint="1,0" StartPoint="0,1">
        <GradientStop Color="#FF032236" Offset="0"/>
        <GradientStop Color="#FF095188" Offset="0.20"/>
        <GradientStop Color="#FF032236" Offset="0.35"/>
        <GradientStop Color="#FF095188" Offset="0.50"/>
        <GradientStop Color="#FF032236" Offset="0.65"/>
        <GradientStop Color="#FF095188" Offset="0.80"/>
        <GradientStop Color="#FF032236" Offset="1"/>
    </LinearGradientBrush>

    <RadialGradientBrush x:Key="RedRadialGradientBrush" GradientOrigin=".2,.2">
        <GradientStop Offset="0.2" Color="#FFFF9999"/>
        <GradientStop Offset="0.5" Color="#FFFC0808"/>
    </RadialGradientBrush>

    <RadialGradientBrush x:Key="GreenRadialGradientBrush" GradientOrigin=".2,.2">
        <GradientStop Offset="0.2" Color="#FFB3FF46"/>
        <GradientStop Offset="0.5" Color="#FF2EB30D"/>
    </RadialGradientBrush>

    <RadialGradientBrush x:Key="YellowRadialGradientBrush" GradientOrigin=".2,.2">
        <GradientStop Offset="0.2" Color="#FFFFFFFF"/>
        <GradientStop Offset="0.5" Color="#FFE8E831"/>
    </RadialGradientBrush>

    <RadialGradientBrush x:Key="GrayRadialGradientBrush" GradientOrigin=".2,.2">
        <GradientStop Offset="0.2" Color="#FFA6A6A6"/>
        <GradientStop Offset="0.5" Color="#FF767676"/>
    </RadialGradientBrush>

    <RadialGradientBrush x:Key="WhiteRadialGradientBrush" GradientOrigin=".2,.2">
        <GradientStop Offset="0.5" Color="#FFF0F0F0"/>
        <GradientStop Offset="0.2" Color="#FFD4D4D4"/>
    </RadialGradientBrush>

    <RadialGradientBrush x:Key="BlueRadialGradientBrush" GradientOrigin=".2,.2">
        <GradientStop Offset="0.5" Color="#FF2588D8"/>
        <GradientStop Offset="0.2" Color="#FF65AAE2"/>
    </RadialGradientBrush>
   
    <DropShadowEffect x:Key="TextDarkShadowEffect" BlurRadius="2" Color="#FF064885" Direction="310" ShadowDepth="1"/>
    <DropShadowEffect x:Key="TextLightShadowEffect" BlurRadius="2" Color="#FFFFFFFF" Direction="310" ShadowDepth="1"/>
    
    <Style TargetType="TextBlock" x:Key="RequiredLabel">
        <Setter Property="Margin" Value="5,5,0,5" />
    </Style>

    <Style TargetType="TextBlock" x:Key="RequiredMarker">
        <Setter Property="Text" Value="*" />
        <Setter Property="Foreground" Value="#FFCC0000" />
        <Setter Property="Margin" Value="2,3,-1,5" />
    </Style>

    <Style x:Key="MainTitleStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="{StaticResource MainTitleForegroundBrush}"/>
        <Setter Property="Effect" Value="{StaticResource TextDarkShadowEffect}"/>
        <Setter Property="FontSize" Value="30"/>        
    </Style>

    <Style x:Key="CenterAlignCellStyle" TargetType="sdk:DataGridCell">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridCell}">
                    <Grid Background="{TemplateBinding Background}">
                        <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" />                        
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="sdk:DataGridCell.IsSelected" Value="True">
                <Setter Property="Background" Value="#FF9EA7BF"/>
                <Setter Property="BorderBrush" Value="#FF9EA7BF"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="Grid">
        <Setter Property="Validation.ErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <AdornedElementPlaceholder />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style TargetType="TextBox">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Width" Value="{StaticResource LargerItemSize}" />
        <Setter Property="Margin" Value="5" />  
        <Setter Property="MinHeight" Value="22"/>
        <Setter Property="Validation.ErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <Grid>
                        <Polygon Points="0,0 10,0 0,10 0,0" HorizontalAlignment="Right" Fill="Red" FlowDirection="RightToLeft" />
                        <Border BorderBrush="Red" BorderThickness="1">
                            <AdornedElementPlaceholder Name="ControlWithError" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}" />
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <Style TargetType="{x:Type ComboBox}">
        <Setter Property="Width" Value="{StaticResource LargerItemSize}"/>
        <Setter Property="Height" Value="Auto"/>
        <Setter Property="MinHeight" Value="22"/>
        <Setter Property="Margin" Value="2"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="HorizontalAlignment" Value="Left"/>
    </Style>
    
    <Style TargetType="CheckBox">
        <Setter Property="Margin" Value="5"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>        
    </Style>

    <!--<Style x:Key="DataGridColumnHeaderStyle" TargetType="sdk:DataGridColumnHeader">
        <Setter Property="Height" Value="25"/>
        <Setter Property="Background" Value="{StaticResource HeaderRowBackgroundBrush}"/>            
        <Setter Property="Foreground" Value="#FF000000"/>        
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="HorizontalContentAlignment" Value="Center" />        
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="ToolTip" Value="Click to sort."/>
            </Trigger>
        </Style.Triggers>
    </Style>-->

    <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ColumnHeaderLeftGripperStyle" BasedOn="{StaticResource ColumnHeaderGripperStyle}"  TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" Name="Border">
                        <!--<Canvas>
                                <Line RenderOptions.EdgeMode="Aliased" X1="7" Y1="{Binding ElementName=Border, Path=ActualHeight}"
                                      X2="7" Y2="0" Stroke="DarkGray"/>
                            </Canvas>-->
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DataGridColumnHeaderStyle" TargetType="{x:Type sdk:DataGridColumnHeader}">
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Height" Value="25"/>
        <Setter Property="Background" Value="{StaticResource HeaderRowBackgroundBrush}"/>
        <Setter Property="Foreground" Value="#FF000000"/>        
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type sdk:DataGridColumnHeader}">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="SortStates">
                                <VisualState x:Name="Unsorted" />
                                
                                <VisualState x:Name="SortAscending">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="UpArrow" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>

                                <VisualState x:Name="SortDescending">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DownArrow" Storyboard.TargetProperty="Visibility">
                                            <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <Border x:Name="BackgroundBorder" BorderThickness="0,1,0,1" 
                              Background="{StaticResource HeaderRowBackgroundBrush}"                               
                              Grid.ColumnSpan="2" />

                        <ContentPresenter Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center" />

                        <Thumb x:Name="PART_LeftHeaderGripper"
                                   HorizontalAlignment="Left"
                                   Style="{StaticResource ColumnHeaderGripperStyle}"/>
                        <Thumb x:Name="PART_RightHeaderGripper"
                                   HorizontalAlignment="Right"
                                   Style="{StaticResource ColumnHeaderLeftGripperStyle}"/>

                        <Path Name="UpArrow" Fill="Black" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" Visibility="Hidden">
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure StartPoint="0,0">
                                        <LineSegment Point="6,0"/>
                                        <LineSegment Point="3,5"/>
                                        <LineSegment Point="0,0"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                        <Path Name="DownArrow" Fill="Black" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" Visibility="Hidden">
                            <Path.Data>
                                <PathGeometry>
                                    <PathFigure StartPoint="0,5">
                                        <LineSegment Point="6,5"/>
                                        <LineSegment Point="3,0"/>
                                        <LineSegment Point="0,5"/>
                                    </PathFigure>
                                </PathGeometry>
                            </Path.Data>
                        </Path>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="ToolTip" Value="Click to sort."/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="sdk:DataGrid">
        <Setter Property="SelectionUnit" Value="FullRow" />
        <Setter Property="CanUserResizeColumns" Value="True" />
        <Setter Property="CanUserReorderColumns" Value="True" />
        <Setter Property="CanUserSortColumns" Value="True" />
        <Setter Property="AlternatingRowBackground" Value="#FFDEE7EE" />
        <Setter Property="AutoGenerateColumns" Value="False" /> 
        <Setter Property="ColumnHeaderStyle" Value="{StaticResource DataGridColumnHeaderStyle}" />
        <Setter Property="GridLinesVisibility" Value="Vertical"/>
        <Setter Property="VerticalGridLinesBrush" Value="#FFE1E9EE" />
        <Setter Property="CanUserAddRows" Value="False" />
        <Setter Property="CanUserDeleteRows" Value="True"/>
        <Setter Property="HorizontalScrollBarVisibility" Value="Hidden" />
        <Setter Property="VerticalScrollBarVisibility" Value="Auto" />               
    </Style>
    
    <Style TargetType="sdk:DataGridCell">
        <Style.Triggers>
            <Trigger Property="sdk:DataGridCell.IsSelected" Value="True">
                <Setter Property="Background" Value="#FF9EA7BF"/>
                <Setter Property="BorderBrush" Value="#FF9EA7BF"/>
            </Trigger>
        </Style.Triggers>
    </Style>
        
    <Style TargetType="Button">
        <Setter Property="Cursor" Value="Hand" />   
        <Setter Property="Width" Value="{StaticResource XSmallItemSize}" />
        <Setter Property="Height" Value="Auto"/>        
        <Setter Property="Padding" Value="0,-2,0,-2"/>
        <Setter Property="Margin" Value="2"/>
    </Style>
    
    <Style TargetType="Button" x:Key="HomeButtonStyle">
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Margin" Value="2"/>
        <Setter Property="Width" Value="{StaticResource LargeItemSize}"/>
        <Setter Property="Height" Value="40"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <!--<Setter Property="FontSize" Value="{StaticResource TextSize}"/>-->
    </Style>

    <Style TargetType="{x:Type MenuItem}" x:Key="MenuSeparatorStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type MenuItem}">
                    <Separator HorizontalAlignment="Stretch" IsEnabled="false"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Menu}" x:Key="MenuStyle">
        <Setter Property="Background" Value="Transparent"/>
    </Style>

    <Style TargetType="{x:Type MenuItem}" x:Key="MenuItemStyle">
        <Setter Property="Command" Value="{Binding Command}" />        
        <!--<Setter Property="FontSize" Value="12"/>-->
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="Margin" Value="1"/>
        <Setter Property="Background" Value="Transparent"/>        
        <!--<Style.Triggers>
            <Trigger Property="MenuItem.IsMouseOver" Value="true">
                <Setter Property="Foreground" Value="#FFFFFFFF"/>
                <Setter Property="Effect" Value="{StaticResource TextDarkShadowEffect}"/>
            </Trigger>
        </Style.Triggers>-->

        <!--<Setter Property="Icon">
                    <Setter.Value>
                        <Image Source="{Binding Icon, Converter={StaticResource StringToBitmapConverter}}" />
                    </Setter.Value>
                </Setter>-->
    </Style>

    <Style TargetType="TextBlock">
        <Setter Property="Margin" Value="5" />
        <Setter Property="TextAlignment" Value="Right" />
        <Setter Property="HorizontalAlignment" Value="Right" />        
        <!--<Setter Property="FontSize" Value="{StaticResource TextSize}" />-->
        <Setter Property="VerticalAlignment" Value="Center" />
    </Style>
    
    <Style TargetType="{x:Type ListBox}">
        <Setter Property="AlternationCount" Value="2"/>
    </Style>
    
    <Style TargetType="{x:Type ListBoxItem}">
        <Style.Triggers>
            <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                <Setter Property="Background" Value="#FFDEE7EE"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <util:MenuItemStyleSelector x:Key="MenuItemStyleSelector"/>

    <conv:NotConverter x:Key="NotConverter"/>
    <conv:DictionaryToKeyValuePairConverter x:Key="DictionaryToKeyValuePairConverter"/>    
    <conv:ObjectToVisibilityConverter x:Key="ObjectToVisibilityConverter" />
    <conv:RoleBasedVisibilityConverter x:Key="RoleBasedVisibilityConverter" />
    <conv:StringToStatusColorConverter x:Key="StringToStatusColorConverter" />
    <conv:StringToBooleanConverter x:Key="StringToBooleanConverter"/>
    
    <ControlTemplate x:Key="HyperlinkStyleButtonTemplate" TargetType="Button">
        <TextBlock Text="{TemplateBinding Content}" TextDecorations="Underline" Cursor="Hand" 
                   HorizontalAlignment="Center" Width="Auto" Height="Auto" Foreground="{TemplateBinding Foreground}"/>
    </ControlTemplate>
    
    <ControlTemplate x:Key="ImageButtonTemplate" TargetType="Button">
        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
            <Image Source="{TemplateBinding Content}" Width="16" Height="16" />
            <TextBlock Text="{TemplateBinding Tag}" />
        </StackPanel>
    </ControlTemplate>
    
    <ControlTemplate x:Key="RoundButtonTemplate" TargetType="Button">
        <Grid>
            <Ellipse HorizontalAlignment="Center" VerticalAlignment="Center" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Fill="{TemplateBinding Background}"/>
            <TextBlock Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" />
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="LargeImageButtonTemplate" TargetType="Button">
        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
            <Image Source="{TemplateBinding Content}" Width="32" Height="32" />
            <TextBlock Text="{TemplateBinding Tag}" />
        </StackPanel>
    </ControlTemplate>

</ResourceDictionary>